<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="UTF-8">
	<title>站点数据</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" th:href="@{/resources/favicon.ico}">
	<link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all"/>
	<link rel="stylesheet" th:href="@{/resources/css/public.css}" media="all"/>
</head>
<style>
	.layui-form-item {
		margin-bottom: 10px;
		clear: both;
		*zoom: 1;
	}
</style>
<body class="childrenBody">
<!-- 查询条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;">
  <legend>查询条件</legend>
</fieldset>
<blockquote class="layui-elem-quote">
	<form method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form-pane">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">客户名称</label>
				<div class="layui-input-inline">
					<input type="text" name="customer" autocomplete="off" class="layui-input">
				</div>
			</div>
		    <div class="layui-inline">
		      <label class="layui-form-label">站点名称</label>
		      <div class="layui-input-inline">
		        <input type="text" name="sitename"  autocomplete="off" class="layui-input">
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label">联系方式</label>
		      <div class="layui-input-inline">
		        <input type="text" name="telephone"  autocomplete="off" class="layui-input">
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label">创建开始</label>
		      <div class="layui-input-inline">
		        <input type="tel" name="startTime" id="startTime" readonly="readonly"  class="layui-input">
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label">创建结束</label>
		      <div class="layui-input-inline">
		        <input type="tel" name="endTime"  id="endTime"  readonly="readonly"   class="layui-input">
		      </div>
		    </div>
			<div class="layui-inline">
				<label class="layui-form-label">更新开始</label>
				<div class="layui-input-inline">
					<input type="tel" name="startUpdateTime" id="startUpdateTime" readonly="readonly"   class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">更新结束</label>
				<div class="layui-input-inline">
					<input type="tel" name="endUpdateTime"  id="endUpdateTime"  readonly="readonly"   class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">提交人</label>
				<div class="layui-input-inline">
					<input type="text" name="submitter" autocomplete="off" class="layui-input">
				</div>
			</div>
		  </div>
		  <div class="layui-form-item">
		      <div class="layui-input-block" style="text-align: center;margin-left: 0px">
		      	<button type="button" id="doSearch" class="layui-btn" lay-submit="" lay-filter="doSearch"><span class="layui-icon layui-icon-search"></span>查询</button>
      			<button type="button" id="doReset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
		      </div>
		  </div>
	</form>
</blockquote>
<!-- 查询条件结束-->

<!-- 数据表格开始 -->
<div>
	<table class="layui-hide" id="siteTable" lay-filter="siteTable"></table>
	<div id="siteToolBar" style="display: none;">
		<button type="button" shiro:hasPermission="site:create" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>添加站点</button>
		<button type="button" shiro:hasPermission="site:update" lay-event="update" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-edit"></span>更新</button>
		<button type="button" shiro:hasPermission="site:delete" lay-event="delete" class="layui-btn layui-btn-sm layui-btn-danger"><span class="layui-icon layui-icon-delete"></span>删除</button>
		<button type="button" shiro:hasPermission="site:batchdelete"  lay-event="batchDelete" class="layui-btn layui-btn-sm layui-btn-danger"><span class="layui-icon layui-icon-delete"></span>批量删除</button>
	</div>
<!--	<div id="siteRowBar" style="display: none;">-->
<!--		<button type="button" lay-event="update" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-edit"></span>更新</button>-->
<!--		<button type="button" lay-event="delete" class="layui-btn layui-btn-sm layui-btn-danger"><span class="layui-icon layui-icon-delete"></span>删除</button>-->
<!--	</div>-->
</div>
<!-- 数据表格结束 -->

<!-- 添加和修改的弹出层开始 -->
<div style="display: none;padding: 5px" id="addOrUpdateDiv">
	<form action="" method="post" class="layui-form layui-form-pane" id="dataFrm" lay-filter="dataFrm">
		<div class="layui-form-item">
			<fieldset>
				<legend>客户信息</legend>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">CustID</label>
						<div class="layui-input-block">
							<input type="hidden" name="id">
							<input type="text" style="display: inline-block;width: 190px" name="custid"   autocomplete="off"  class="layui-input">
						</div>
					</div>
<!--					<div class="layui-inline">-->
<!--						<label class="layui-form-label">客户名称<span style="color:red;">*</span></label>-->
<!--						<div class="layui-input-block">-->
<!--							<select name="customer" lay-verify="" lay-search>-->
<!--								<option value="0"></option>-->
<!--								<option value="010">layer</option>-->
<!--								<option value="021">form</option>-->
<!--								<option value="0571">layim</option>-->
<!--							</select>-->
<!--						</div>-->
<!--					</div>-->
					<div class="layui-inline">
						<label class="layui-form-label" style="color: red">客户名称</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="customer"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">站点名称</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="sitename"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">姓名</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="name"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">联系方式</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="telephone"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">帮我吧ID</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="help"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">职位</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="post"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">问题处理状态</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="problem" autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
			</fieldset>
			<fieldset>
				<legend>站点程序版本/其他信息</legend>
				<div class="layui-form-item">
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label">部署方式</label>
						<div class="layui-input-inline">
							<select name="deployment" id="deployment">
								<option value="0">请选择部署方式</option>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">95A1版本</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="s95a1v"   autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">95A2版本</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="s95a2v"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">9592版本</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="s9592v"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">9511版本</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="s9511v"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">9512版本</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="s9512v"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">9001版本</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="s9001v"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label" style="font-size: 11px">档案信息来源</label>
						<div class="layui-input-inline">
							<select name="sourceofcustomer" id="sourceofcustomer">
								<option value="0">请选择档案信息来源</option>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">中心数据库</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="centerdbv"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">油站数据库</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="oildbv"   autocomplete="off"  class="layui-input">
						</div>
					</div>

					<div class="layui-inline">
						<label class="layui-form-label">云智付</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="cloudv"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">青蛙付</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="frogv"   autocomplete="off" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">智慧大屏</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 504px" name="wisdom"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">自助服务机</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="selfservice"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">油机情况</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="oilengine"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
			</fieldset>
			<fieldset>
				<legend>备注</legend>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<textarea style="display: inline-block;width: 505px;height: 100px" name="message" class="layui-textarea"></textarea>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block" style="text-align: center;margin-left: 0px">
						<button type="button" class="layui-btn" lay-submit="" lay-filter="doSubmit" id="doSubmit" ><span class="layui-icon layui-icon-add-1"></span>提交</button>
						<button type="reset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
					</div>
				</div>
			</fieldset>
		</div>
	</form>
</div>
<!-- 添加和修改的弹出层结束 -->

<script type="text/javascript" th:src="@{/resources/layui/layui.js}"></script>
<script type="text/javascript">
	layui.use(['jquery','element','form','table','layer','laydate','layedit'],function(){
		var $=layui.jquery;
		var form=layui.form;
		var table=layui.table;
		var layer=layui.layer;
		var laydate=layui.laydate;
		var layedit=layui.layedit;
		var element=layui.element;
		//初始化时间选择器
		laydate.render({
			elem:'#startTime',
			type:'datetime'
		});
		laydate.render({
			elem:'#endTime',
			type:'datetime'
		});
		laydate.render({
			elem:'#startUpdateTime',
			type:'datetime'
		});
		laydate.render({
			elem:'#endUpdateTime',
			type:'datetime'
		});
		//初始化富文本
		var editIndex = layedit.build('content');
		//加载 数据
		var tableIns=table.render({
			 elem: '#siteTable'
		    ,url:'/site/loadAllSite'
		    ,toolbar: '#siteToolBar' //开启头部工具栏，并为其绑定左侧模板
		    ,title: '站点数据'
		    ,height:'full-260'
			,limit:'20'
			,limits:[20,40,60,80]
		    ,page: true
		    ,cols: [ [
		      {type: 'checkbox', fixed: 'left'}
		      ,{field:'id', title:'ID',align:'center',width:'100'}
		      ,{field:'custid', title:'CustID',align:'center',width:'100'}
		      ,{field:'customer', title:'客户名称',align:'center',width:'150'}
		      ,{field:'sitename', title:'站点名称',align:'center',width:'180'}
		      ,{field:'name', title:'姓名',align:'center',width:'100'}
		      ,{field:'post', title:'职位',align:'center',width:'100'}
		      ,{field:'telephone', title:'联系方式',align:'center',width:'150'}
		      ,{field:'help', title:'帮我吧ID',align:'center',width:'140'}
		      ,{field:'deployment', title:'部署方式',align:'center',width:'100'}
		      ,{field:'s95a1v', title:'95A1',align:'center',width:'140'}
		      ,{field:'s95a2v', title:'95A2',align:'center',width:'140'}
		      ,{field:'s9511v', title:'9511',align:'center',width:'140'}
		      ,{field:'s9512v', title:'9512',align:'center',width:'140'}
		      ,{field:'s9001v', title:'9001',align:'center',width:'140'}
		      ,{field:'s9592v', title:'9592',align:'center',width:'140'}
		      ,{field:'centerdbv', title:'中心数据库',align:'center',width:'140'}
		      ,{field:'oildbv', title:'油站数据库',align:'center',width:'140'}
		      ,{field:'cloudv', title:'云智付',align:'center',width:'140'}
		      ,{field:'frogv', title:'青蛙付',align:'center',width:'140'}
		      ,{field:'wisdom', title:'智慧大屏',align:'center',width:'220'}
		      ,{field:'selfservice', title:'自助服务机',align:'center',width:'140'}
		      ,{field:'oilengine', title:'油机情况',align:'center',width:'140'}
		      ,{field:'message', title:'备注',align:'center',width:'150'}
		      ,{field:'sourceofcustomer', title:'客户来源',align:'center',width:'100'}
		      ,{field:'submitter', title:'创建人',align:'center',width:'100'}
		      ,{field:'submissiontime', title:'创建时间',align:'center',width:'180'}
		      ,{field:'updatebody', title:'更新人',align:'center',width:'100'}
		      ,{field:'updatetime', title:'更新时间',align:'center',width:'180'}
		      ,{field:'problem', title:'问题处理状态',align:'center',width:'180'}
		      // ,{fixed: 'right', title:'操作', toolbar: '#siteRowBar',align:'center',width:'250'}
		    ] ]
		});

		//模糊查询
		$("#doSearch").click(function () {
			var params=$("#searchFrm").serialize();
			tableIns.reload({
				url:'/site/loadAllSite?'+params,
				page:{
					curr:1
				}
			});
			return false;
		})
		$("#doReset").click(function () {
			$("#searchFrm")[0].reset()
			$("#doSearch").click()
		})
		var data;
		//监听工具条的事件
		table.on("toolbar(siteTable)",function(obj){
			 switch(obj.event){
			    case 'batchDelete':
			     batchDelete();
			    break;
			    case 'add':
			     openAddLayer();
			    break;
			 	case 'update':
				 var checkStatus = table.checkStatus('siteTable');
				 var data =checkStatus.data[0];
				 openUpdateSiteLayer(data);
			 	break;
			 	case 'delete':
				 var checkStatus = table.checkStatus('siteTable');
				 var data =checkStatus.data[0];
				 deleteSite(data);
			 	break;
			  }
		});

		// //监听行工具条的事件
		// table.on("tool(siteTable)",function(obj){
		// 	  var data = obj.data; //获得当前行数据
		// 	 switch(obj.event){
		// 	    case 'update':
		// 	   		openUpdateSiteLayer(data);
		// 	    break;
		// 	    case 'delete':
		// 	   		deleteSite(data);
		// 	    break;
		// 	  }
		// });
		//
		var mainIndex;
		var url;
		//打开添加的弹出层
		function openAddLayer(){
			mainIndex=layer.open({
				type:1,
				content:$("#addOrUpdateDiv"),
				area:['1310px','660px'],
				title:'添加站点',
				success:function(){
					$("#dataFrm")[0].reset();
					url="/site/addSite";
					initDeploymentSelects();
					initSourceOfCustomerSelects();
				}
			});
		}
		// //加载客户数据下拉列表
		// function initCustomerSelect(customer){
		// 	var dom=$("#customer");
		// 	dom.html("");
		// 	$.get("/customer/loadAllCustomerSelect",function(res){
		// 		var data=res.data;
		// 		var dom=$("#customer");
		// 		var html='<option value="0">请选择客户</option>'
		// 		$.each(data,function(index,item){
		// 			html+='<option value="'+item.id+'">'+item.customer+'</option>'
		// 		});
		// 		dom.html(html);
		// 		if(customer!=undefined){
		// 			dom.val(customer);
		// 		}
		// 		form.render("select");
		// 	});
		// }
		//加载部署方式数据下拉列表
		function initDeploymentSelect(data){
			var dom=$("#deployment");
			dom.html("");
			$.get("/customer/loadAllDeploymentSelect",function(res){
				var redata=res.data;
				var dom=$("#deployment");
				var html='<option value="0">请选择部署方式</option>'
				$.each(redata,function(index,item){
					if(data.deployment===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initDeploymentSelects(){
			var dom=$("#deployment");
			dom.html("");
			$.get("/customer/loadAllDeploymentSelect",function(res){
				var data=res.data;
				var dom=$("#deployment");
				var html='<option value="0">请选择部署方式</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//加载客户来源类型下拉列表
		function initSourceOfCustomerSelect(data){
			var dom=$("#sourceofcustomer");
			dom.html("");
			$.get("/customer/loadAllSourceOfCustomerSelect",function(res){
				var redata=res.data;
				var dom=$("#sourceofcustomer");
				var html='<option value="0">请选择档案信息来源</option>'
				$.each(redata,function(index,item){
					if(data.sourceofcustomer===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initSourceOfCustomerSelects(){
			var dom=$("#sourceofcustomer");
			dom.html("");
			$.get("/customer/loadAllSourceOfCustomerSelect",function(res){
				var data=res.data;
				var dom=$("#sourceofcustomer");
				var html='<option value="0">请选择档案信息来源</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//打开修改的弹出层
		function openUpdateSiteLayer(data){
			mainIndex=layer.open({
				type:1,
				content:$("#addOrUpdateDiv"),
				area:['1310px','660px'],
				title:'修改站点',
				success:function(){
					$("#dataFrm")[0].reset();
					//装载新的数据
					form.val("dataFrm",data);
					layedit.setContent(editIndex,data.content);
					url="/site/updateSite";
					initDeploymentSelect(data);
					initSourceOfCustomerSelect(data);
				}
			});
		}
		$("#doSubmit").click(function(){
			layedit.sync(editIndex);
			var data=$("#dataFrm").serialize();
			$.post(url,data,function(res){
				if(res.code==200){
					tableIns.reload();
					layer.close(mainIndex);
				}
				layer.msg(res.msg);
			})
		})
		//删除
		function deleteSite(data){
			layer.confirm('你确定要删除【'+data.customer+data.sitename+'】这条站点数据吗?', {icon: 3, title:'提示'}, function(index){
				$.post("/site/deleteSite",{id:data.id},function(res){
					if(res.code==200){
						tableIns.reload();
					}
					layer.msg(res.msg);
				})
			   layer.close(index);
			});
		}

		//批量删除
		function  batchDelete(){
			//得到选中行
			var checkStatus = table.checkStatus('siteTable');
			var dataLength=checkStatus.data.length;
			if(dataLength>0){
				layer.confirm('你确定要删除这些站点数据吗?', {icon: 3, title:'提示'}, function(index){
						var data=checkStatus.data; //获取选中行的数据
						var ids="";
						$.each(data,function(index,item){
							if(index==0){
								ids+="ids="+item.id;
							}else{
								ids+="&ids="+item.id;
							}
						})
						$.post("/site/batchDeleteSite",ids,function(res){
							if(res.code==200){
								tableIns.reload();
							}
							layer.msg(res.msg);
						})
					   layer.close(index);
					});
			}else{
				layer.msg("请选中操作行")
			}
		}


	});
</script>
</body>
</html>
